<?php

class pos{

	public $user_id;
	public $date;
	public $pos_id;
	public $sale_transaction_id;
	public $money;
	public $action;
	public $type;
	public $comment;
	public $username;
	public $password;

	public function pos(){

		$this->user_id	= $_SESSION['USERID'];
		$this->date		= date('Y-m-d H:i:s');

	}
	
	
	
	public function pos_sale($pos_id, $sale_transaction_id, $money){
		
		$this->pos_id 				= $pos_id;
		$this->sale_transaction_id 	= $sale_transaction_id;
		$this->money				= $money;
		$this->action 				= '1';
		$this->type					= 1;
		
		mysql_query("INSERT INTO `pos_money_action`
						(`user_id`, `date`, `pos_id`, `sale_transaction_id`, `money`, `action`, `type`)
					 VALUES
						($this->user_id, '$this->date', $this->pos_id, $this->sale_transaction_id,  $this->money, '$this->action', $this->type)
		");
		
	}
	
	public function pos_in($usr_id, $pos_id, $money, $comment){
		$this->usr_id  = $usr_id;
		$this->pos_id  = $pos_id;
		$this->money   = $money;
		$this->comment = $comment;
		$this->action  = 1;
		$this->type    = 2;
		
		mysql_query("INSERT INTO `pos_money_action`
						(`user_id`, `date`, `pos_id`, `money`, `action`, `type`, `comment`)
					 VALUES
						($this->usr_id, '$this->date', $this->pos_id,  $this->money, '$this->action', $this->type, '$this->comment')
		");
		
		
	}
	public function pos_out($usr_id, $pos_id, $money, $comment){
		$this->usr_id  = $usr_id;
		$this->pos_id 	= $pos_id;
		$this->money	= $money;
		$this->comment  = $comment;
		$this->action 	= '2';
		$this->type		= 1;
		
		mysql_query("INSERT INTO `pos_money_action`
						(`user_id`, `date`, `pos_id`, `money`, `action`, `type`, `comment`)
					VALUES
						($this->usr_id, '$this->date', $this->pos_id, $this->money, '$this->action', $this->type, '$this->comment')
		");
		
	}

// 	public function pos_check($pos_id, $money, $comment){
	
// 		$this->pos_id 	= $pos_id;
// 		$this->money	= $money;
// 		$this->comment  = $comment;
// 		$this->status	= 0;
	
// 		mysql_query("INSERT INTO pos_check
//      (pos_check.pos_id, pos_check.pos_user_id, pos_check.check_date, pos_check.money_in_pos, pos_check.real_money, pos_check.`status`)
// 		VALUES
//       ($this->pos_id, $this->user_id, '$this->date', 90.9, $this->money, $this->status)
// 	  ");
	
// 	}
	
	public function CheckUser($username, $password){
		$this->username  = $username;
		$this->password  = md5($password);

		if ($this->username != '' && $this->password != '' ) {
				
			$result = mysql_query("
					SELECT 	`id`
					FROM 	`users`
					WHERE	`password` = '$this->password' AND username = '$this->username' AND `actived` = 1
					");
			if (mysql_num_rows($result) == 1) {
				return true;
			}else{
				return false;
			}
		}else{
			return false;
		}
	}
	
	 
}


	?>